package com.symc.his.api.impl.doctor;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.symc.his.api.base.BaseApiService;
import com.symc.his.api.base.BaseResponse;
import com.symc.his.api.doctor.DiagnosticLibraryService;
import com.symc.his.api.doctor.dto.resp.DiagnosticLibraryRespDTO;
import com.symc.his.api.impl.entity.DiagnosticLibraryDO;
import com.symc.his.api.impl.mapper.DiagnosticLibraryMapper;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @CreateTime: 2023/4/18 23:59
 * @Version:
 * @Since: 1.8
 * @Author: 辛凤文 forward.seen@foxmail.com
 */
@RestController
public class DiagnosticLibraryServiceImpl extends BaseApiService implements DiagnosticLibraryService {

    @Resource
    private DiagnosticLibraryMapper diagnosticLibraryMapper;

    @Override public BaseResponse<DiagnosticLibraryRespDTO> queryDiagnosticListByName(String diagnosisName) {
        if (StringUtils.isEmpty(diagnosisName)) {
            return setResultError("查询数据diagnosisName不得为空");
        }
        LambdaQueryWrapper<DiagnosticLibraryDO> queryWrapper = new LambdaQueryWrapper<DiagnosticLibraryDO>()
            .like(DiagnosticLibraryDO::getDiagnosisName, diagnosisName);
        List<DiagnosticLibraryDO> diagnosticLibraryDOS = diagnosticLibraryMapper.selectList(queryWrapper);
        List<DiagnosticLibraryRespDTO> libraryRespDTOS = diagnosticLibraryDOS.stream().map(e -> DO2DTO(e, DiagnosticLibraryRespDTO.class)).collect(Collectors.toList());
        return setResultSuccess(libraryRespDTOS);
    }
}